package IntegrationTest;

import static org.junit.Assert.*;

import java.text.ParseException;

import org.junit.Before;
import org.junit.Test;

import Logic.DSLogic;
import Logic.DSTaskFactory;
import Object.DSException;
import Storage.DSStorage;
import Task.DSTask;
//@author A0105536L
public class LogicStorageIntegrationTest {
	DSLogic _logic;
	DSStorage _storage;
	DSTaskFactory _task;
	
	@Before
	public void setUp() throws Exception {
	}
		
	@Test
	public void test_Logic_Storage_add() throws ParseException, DSException {
		_logic = new DSLogic();
		_storage = new DSStorage();
		_task = new DSTaskFactory();
		DSTask task = new DSTask();
		task = _task.createNewTask("This is integration test"); 
		assertEquals(_storage.add(task),_logic.getExecuter().add(task));
		
	}

	@Test
	public void test_Logic_Storage_delete() throws ParseException, DSException {
		_logic = new DSLogic();
		_storage = new DSStorage();
		_task = new DSTaskFactory();
		DSTask task = new DSTask();
		task = _task.createNewTask("This is integration test"); 
		assertEquals(_storage.remove(task.getTaskId()),_logic.getExecuter().delete(task.getTaskId()));
		
	}
	
	@Test
	public void test_Logic_Storage_update() throws ParseException, DSException {
		_logic = new DSLogic();
		_storage = new DSStorage();
		_task = new DSTaskFactory();
		DSTask task = new DSTask();
		task = _task.createNewTask("This is integration test"); 
		assertEquals(_storage.update(task),_logic.getExecuter().update(task));
		
	}
}
